package com.myzl.common.enums;

/**
 * 比较类型
 * @author Administrator
 */

public enum CompareType {

    /** 等于 大于 大于等于 小于 小于等于*/
    EQ("1","="),GT("2",">"),GE("3",">="),LT("4","<"),LE("5","<=");
    /** 字符串数字 */
    public String code;
    public String compare;

    private CompareType(String code, String compare){
        this.code = code;
        this.compare = compare;
    }

    /**
     * 通过code获取枚举
     * @param code 编码
     * @return 枚举对象
     */
    public static CompareType getByCode(String code){
        for(CompareType x:values()){
            if(x.code.equals(code)){
                return x;
            }
        }
        return null;
    }


    public static String getCompare(String code) {
        CompareType[] compareTypes = values();
        for (CompareType compareType : compareTypes) {
            if (compareType.code.equals(code)) {
                return compareType.compare;
            }
        }
        return null;
    }

    public static String getCode(String compare) {
        CompareType[] compareTypes = values();
        for (CompareType compareType : compareTypes) {
            if (compareType.compare.equals(compare)) {
                return compareType.code;
            }
        }
        return null;
    }
}
